import logging
import redis


class Config(object):

    # mysql数据库链接地址
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/Flask_iHome"
    # 设置不跟踪数据库的修改
    SQLALCHEMY_TRACK_MODIFICATIONS = True
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True

    # 对redis数据库配置
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379

    # 加密 session
    SECRET_KEY = "!@#$#@$#!%#$@^%^&%#&^%*"

    #设置session信息
    SESSION_TYPE = "redis"  # 存储类型
    SESSION_KEY_PREFIX = "Session:"  # 设置前缀
    SESSION_USE_SIGNER = True  # 签名存储
    SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT)  # 制定存储位置
    PERMANENT_SESSION_LIFETIME = 3600 * 24 * 1  # 设置session一天有效



class DevelopmentMode(Config):
    """开发模式"""
    DEBUG = True
    # 日志等级
    LOG_LV = logging.DEBUG

class ProductionModels(Config):
    """生产模式"""
    DEBUG = False
    # 日志等级
    LOG_LV = logging.DEBUG


config_dict = {
            "develop": DevelopmentMode,
            "product": ProductionModels
        }
